/**
 * 
 */
package calendarInterface2;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


import calendarEventManager.CEMListColor;





/**
 * @author Mohamed Ali Ayed
 *@version 1.0
 */
@SuppressWarnings("serial")
public class FAddAgenda extends FrameAgenda{

	/**
	 * 
	 */
	public FAddAgenda() {
		super();
		this.setTitle("Agenda");
		setSize(300,200);	
		setLocationRelativeTo(null); //center the window
		bSaveAgenda.addActionListener(new ActionAddAgenda());
		bCancelAgenda.addActionListener(new ActionHideFrameAgenda());
		addWindowListener (new WindowAdapter() {
	          public void windowClosing(WindowEvent e) {
	      		CalendarInterface.hideFrameAddAgenda();
	             }
	          }
		);
		this.add(pAgenda);
	}
	class ActionHideFrameAgenda implements ActionListener{
		 
        public void actionPerformed(ActionEvent e) {
        	CalendarInterface.hideFrameAddAgenda();
        }// end actinPerformed               
	}//end classe interne
	
	class ActionAddAgenda implements ActionListener{
		 
        public void actionPerformed(ActionEvent e) {
        	if (tName.getText().equalsIgnoreCase("")){
        		OPError messError = new OPError();
        		messError.showErrorWindow("Saisi incorrecte", "Erreur Saisie");
        	}
        	else {
        		CEMListColor listColor = new CEMListColor();
        		CalendarInterface.addAgenda(tName.getText(), listColor.indexOf((String) CBColor.getSelectedItem()));
        	}
        }// end actinPerformed               
	}//end classe interne

}
